Types of Prompts
Learn about different types of prompts and how to use them.
Prompts can be used to achieve various kinds of tasks. It is essential to understand how to write prompts to attain the desired result effectively. Let's look at different prompt examples and how to use them in various scenarios.
Text summarization#
Text summarization prompts involve generating a summary of a longer text, such as an article, report, or book. The input prompt can be the entire text or a specific passage to be summarized. The output is a condensed version of the input text that captures the main points and key ideas.
These prompts can be used for various applications, such as summarization, document summarization, and research paper summarization, to help people quickly understand the content without having to read the entire text.
Prompt |
Generate a brief summary for the following text: "Penguins are remarkable creatures that live in the icy lands of Antarctica. These flightless birds have a unique way of moving on land and swimming in the water. With their sleek bodies and waterproof feathers, they are perfectly adapted for life in the cold. Penguins come in different sizes, from the small and playful Little Blue Penguins to the tall and regal Emperor Penguins. They have a black and white color pattern, which helps them camouflage in the water. The black feathers on their back absorb heat from the sun, while the white feathers on their belly blend with the ice, keeping them safe from predators. When it's time to find food, penguins dive into the freezing water and use their strong wings to swim swiftly. They have webbed feet that act like paddles, propelling them through the sea. Penguins mostly eat fish and krill, tiny shrimp-like creatures that are found in abundance beneath the icy surface. Penguins are known for their unique way of walking, waddling side to side. This funny walk helps them keep their balance on slippery ice and snow. They gather in large groups called colonies, where they communicate with each other through special calls and body movements. These amazing birds are also great parents. After laying their eggs, the male penguin takes care of them while the female goes to find food. The male penguin keeps the eggs warm by balancing them on his feet and covering them with a warm layer of feathers. Once the chicks hatch, both parents work together to feed and protect them until they are old enough to fend for themselves." |
Output |
Penguins are fascinating flightless birds that inhabit the icy lands of Antarctica. They have adapted to life in the cold with their sleek bodies and waterproof feathers. Penguins come in various sizes and have a black and white color pattern, which helps them blend in and stay safe from predators. They use their strong wings and webbed feet to swim swiftly in search of food, mainly fish and krill. Penguins are known for their waddling walk, which helps them navigate slippery surfaces. They gather in colonies and communicate through special calls and body movements. These birds are exceptional parents, with the male penguin taking care of the eggs while the female goes hunting. Penguins have unique behaviors and adaptations that allow them to survive in the harsh Antarctic environment. Studying these incredible creatures helps us appreciate the wonders of the animal kingdom. |
We can see that the model has summarized the text into a few sentences and tried to convey the essence of the passage.
Information extraction#
Information extraction prompts are used to extract specific information from a given text. These prompts are designed to identify and extract relevant information from a given document or dataset, which can then be used to generate new content.
Let's look at an example:
Prompt |
Nelson Mandela was a South African anti-apartheid revolutionary and political leader who served as the President of South Africa from 1994 to 1999. Mandela was born in 1918 in the Eastern Cape of South Africa and became actively involved in the anti-apartheid movement in the 1940s. He was arrested and imprisoned for 27 years for his opposition to the apartheid regime. During his imprisonment, Mandela became an international symbol of resistance against apartheid, and his release from prison in 1990 was celebrated around the world. Mandela worked tirelessly to negotiate an end to apartheid and bring about a peaceful transition to democracy in South Africa. He was awarded the Nobel Peace Prize in 1993 for his efforts. As President of South Africa, Mandela continued his work to promote reconciliation and healing in the country. He established the Truth and Reconciliation Commission to investigate human rights abuses during the apartheid era and to facilitate the process of national healing. Mandela is widely regarded as a hero and an inspiration to people all over the world for his commitment to justice, equality, and freedom. Identify the dates and corresponding events in a list from the text above. |
Output |
|
Here, we prompt the model to extract the dates and corresponding events from the text. We also specify that the output should be in a list.
Question and answers#
Question prompts are a type of prompt used to generate responses to questions. These prompts are typically structured as a question, and the generated response should be an answer to the question. Question prompts can be used in a variety of applications, such as chatbots, customer service, and search engines.
Prompt |
What are the seven wonders of the ancient world? |
Output |
The Seven Wonders of the Ancient World are:
|
This is an example of a simple question we can ask the model. We can also ask more detailed questions based on a specific context.
Text classification#
Text classification prompts classify or categorize a text into predefined classes or categories. These prompts require the model to analyze the text and determine which category it belongs to based on the content of the text. For example, a text classification prompt can be used to categorize customer reviews of a product as positive, negative, or neutral. The model is trained to recognize specific keywords, phrases, or patterns in the text to make its classification.
Prompt |
Classify the following text into positive, negative, or neutral sentiment: "I bought these cookies because they were very popular. However, they did not taste good. The texture was cakey and the cookies were not fresh. I will not recommend this to my friends." |
Output |
Negative |
Here's an example prompt for classifying reviews based on sentiment. We can do much more with classification, for example, spam detection, topic classification, intent classification, and more.
Translation#
Translation prompts are used to generate text translations from one language to another. The input to the prompt is typically a sentence or a paragraph in the source language, and the output is the corresponding translation in the target language. The prompt should include an instruction, source text, and target language.
Prompt |
Translate the following source text from French to English. Source text: Je suis un étudiant en informatique. Target language: English |
Output |
"I am a computer science student." |
Code generation#
Code generation prompts instruct a generative AI model to create or complete code, given a specific programming language and a set of input parameters. These prompts can generate various types of code, such as functions, classes, or entire programs. Code generation prompts can be useful for automating repetitive coding tasks, generating new code based on existing examples, or even creating new and innovative code solutions.
Prompt |
Write a function that uses the bubble sort algorithm to sort a list of integers in ascending order. Programming language: Python Input example: [5, 8, 1, 0, 3, 9] Output example: [0, 1, 3, 5, 8, 9] |
Output:
In this example, we write a prompt that specifies the coding task by naming the algorithm that should be coded. It also mentions the programming language required and an example of the input and output list. As a result, the model generates an executable code that works exactly as expected.
Reasoning#
One of the most challenging tasks for an LLM is the requirement of reasoning. Reasoning is a fascinating area as it allows for complex applications to arise from LLMs. It's worth noting that to achieve satisfying results for reasoning tasks, we need to use advanced prompting techniques.
Reasoning prompts require the generative AI model to apply logical reasoning and draw conclusions based on the provided information. These prompts can be used for decision-making, problem-solving, and understanding cause-and-effect relationships.
Prompt |
The sum of the odd numbers in this group is an even number: 15, 32, 5, 13, 82, 7, 1. |
Output |
That statement is correct. The odd numbers in the group are 15, 5, 13, 7, and 1, and their sum is 41, which is an even number. The even numbers in the group are 32 and 82. |
In this example, the model is unable to get to the correct answer. Although it identified that the sum of the odd numbers is 41, it failed to recognize that 41 is an odd number. We need to write more explicit instructions and allow the model to process information one step at a time. Let's try a different prompt for the same example.
Prompt |
The sum of the odd numbers in this group is an even number: 15, 32, 5, 13, 82, 7, 1. Solve the problem by breaking it into the following steps:
|
Output |
|
Here, we give the model time to think. The model performs each step and then finally analyzes the result. This time, the model was able to give the correct answer. This example shows us the importance of prompt engineering to achieve the desired results.
Prompts and Prompt Engineering
Prompt Engineering Best Practices